package factories

import (
	"fmt"
	"github.com/brianvoe/gofakeit/v6"
	"github.com/goravel/framework/support/carbon"
	. "goravel/app/models/common"
)

type HistorytrackFactory struct {
}

// Definition Define the model's default state.
func (f *HistorytrackFactory) Definition() map[string]any {
	//
	var coordinates CoordRes
	coordinates.Type = "Point"
	//中国31.279555,107.388487 31.116761,107.558129
	minLatitude := float64(31.0)   // 达州市最南端
	maxLatitude := float64(31.5)   // 达州市最北端
	minLongitude := float64(106.0) // 达州市最西端
	maxLongitude := float64(108.0) // 达州市最东端

	Longitude, _ := gofakeit.LongitudeInRange(minLongitude, maxLongitude)
	Latitude, _ := gofakeit.LatitudeInRange(minLatitude, maxLatitude)
	coordinates.Coordinates = []float64{
		Longitude,
		Latitude,
	}
	time := gofakeit.FutureDate()

	carbonDateTime := carbon.FromStdTime(time)
	//减去2天
	dayOff := gofakeit.RandomInt([]int{1, 2, 3, 4, 5, 6, 7, 8})
	carbonDateTime = carbonDateTime.SubDays(dayOff)
	location_at := carbon.NewDateTime(carbonDateTime)
	//随机1-10
	device_id := gofakeit.RandomInt([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
	address := fmt.Sprintf("%s,%s", "达州市", gofakeit.Address().Address)
	return map[string]any{
		"DeviceID":    device_id,
		"Coordinates": coordinates,
		"Address":     address,
		"LocationAt":  location_at,
	}
}
